<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
    </head>
<body>
<div>
<input type="checkbox" name="" ><span>苹果-</span><span>10</span>
<input type="number" name='num' value="1" min="0">
</div>
<div>
<input type="checkbox" name="" ><span>梨-</span><span>16</span>
<input type="number" name='num' value="1" min="0">
</div>
<p>总价：<span>0</span></p>
<p><input type="checkbox" name="" id="btn">全选</p>
</body>
<script>
   $(function(){
       $('div :checkbox,[name="num"]').change(function(){
           var total = 0
           $('div :checkbox').each(function(){
            if($(this).prop('checked')){
               var price = $(this).next().next().html()
               var num =$(this).next().next().next().val()
               total +=(price*num)           
           }
       })
       $('span').last().html(total)
   })
   $('#btn').change(function(){
       $('div :checkbox').prop('checked',$(this).prop('checked'))
       $('div :checkbox').change()
   }) 
   })
</script>
</html>